<script setup lang="ts">
import PromotionBadge from './PromotionBadge.vue'

interface PricingCardProps {
  name: string
  price: number
  period: string
  color: string
  hasPromotion?: boolean
}

const props = withDefaults(defineProps<PricingCardProps>(), {
  hasPromotion: false
})

const emit = defineEmits<{
  buy: []
}>()

const handleBuy = () => {
  emit('buy')
}
</script>

<template>
  <div class="pricing-card">
    <!-- 限时优惠角标 -->
    <PromotionBadge v-if="props.hasPromotion" />

    <!-- 超大数字价格 -->
    <div class="price-number" :style="{ color: props.color }">
      {{ props.price }}
    </div>

    <!-- 单位和周期 -->
    <div class="price-unit">
      元/{{ props.period }}
    </div>

    <!-- 套餐名称 -->
    <div class="plan-name">
      {{ props.name }}
    </div>

    <!-- 立即购买按钮 -->
    <button
      class="buy-button"
      :style="{
        background: props.color,
        borderColor: props.color
      }"
      @click="handleBuy"
    >
      立即购买
    </button>
  </div>
</template>

<style scoped>
.pricing-card {
  position: relative;
  background: white;
  border-radius: 16px;
  padding: 48px 32px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 320px;
  overflow: visible;
}

.pricing-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* 超大数字 */
.price-number {
  font-size: 140px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: -2px;
  animation: fadeInScale 0.6s ease;
}

/* 单位和周期 */
.price-unit {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin-bottom: 16px;
  animation: fadeInUp 0.6s ease 0.1s backwards;
}

/* 套餐名称 */
.plan-name {
  font-size: 18px;
  font-weight: 500;
  color: #666;
  margin-bottom: 32px;
  animation: fadeInUp 0.6s ease 0.2s backwards;
}

/* 立即购买按钮 */
.buy-button {
  width: 100%;
  max-width: 200px;
  padding: 14px 32px;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  outline: none;
  animation: fadeInUp 0.6s ease 0.3s backwards;
}

.buy-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  filter: brightness(1.1);
}

.buy-button:active {
  transform: scale(0.98);
}

/* 动画效果 */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 平板响应式 */
@media (max-width: 1024px) {
  .price-number {
    font-size: 120px;
  }

  .price-unit {
    font-size: 22px;
  }

  .plan-name {
    font-size: 17px;
  }
}

/* 移动端响应式 */
@media (max-width: 768px) {
  .pricing-card {
    padding: 36px 24px;
    min-height: 280px;
  }

  .price-number {
    font-size: 100px;
  }

  .price-unit {
    font-size: 20px;
    margin-bottom: 12px;
  }

  .plan-name {
    font-size: 16px;
    margin-bottom: 24px;
  }

  .buy-button {
    max-width: 180px;
    padding: 12px 28px;
    font-size: 15px;
  }
}

/* 超小屏幕 */
@media (max-width: 480px) {
  .price-number {
    font-size: 80px;
  }

  .price-unit {
    font-size: 18px;
  }

  .plan-name {
    font-size: 15px;
  }
}
</style>
